package cn.edu.scau.cmi.lixiaoyuan.Singleton;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;

import cn.edu.scau.cmi.lixiaoyuan.multition.Marshal;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class Control implements Initializable {
   public List<String> list = new ArrayList<String>();
   
   String str = "";
   
   @FXML
   private Button myButton;

   @FXML
   private TextField myTextField;
   
   @FXML
   private Button mybutton2;

   @FXML
   private TextField myTextField2;
   
   @FXML
   private TextArea myTextarea;
   
   @Override
   public void initialize(URL location, ResourceBundle resources) {

       // TODO (don't really need to do anything here).

   }

   // When user click on myButton
   // this method will be called.
   public void showSingleton(ActionEvent event) {
       
       Chairman instance = Chairman.getSingleInstance(myTextField.getText());
       str = str+instance.getName()+":"+instance+"\r\n";
       myTextarea.setText(str);
      
       
   }
   
   public void showSingletonSecond(ActionEvent event) {
      

       String message = Marshal.getString(myTextField2.getText());
      
       str = str+message+"\r\n";
       
       myTextarea.setText(str);
      
       
   }
   
}

